#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int L_year(int year1)
{
	if ((year1 % 4 == 0 && year1 % 100 != 0) || year1 % 400)
		return 1;
	else
		return 0;
}
int G_y_m(int year, int mouth)
{
	int day = 0;
	int days[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	
	day = days[mouth];
	if (L_year(year) == 1 && mouth == 2)
	{
		day++;
	}
		return day;
}

int main()
{
	int y = 0;
	int m = 0;
	scanf("%d %d", &y, &m);

	int a=G_y_m(y,m);
	printf("%d", a);
	return 0;
}